<?php

class Dashboard extends CI_Controller {

    function __construct() {
        parent::__construct();
        if ($this->session->userdata('logged_in')) {
            $session_data = $this->session->userdata('logged_in');
            $data['username'] = $session_data['username'];
        } else {
            redirect('user_login/user', 'refresh');
        }
        $this->load->model('user');
        $this->load->model('user_role');
        $this->load->helper('user_helper');

        if ($this->cek() == 0) {
            redirect('user_login/user', 'refresh');
        }
    }

    function index() {
        $data['id'] = $this->id();
        $data['access'] = $this->user_role->access($this->cek());
        $data['user_access'] = $this->cek();
        $data['content'] = 'dashboard/index';
        $this->load->view('template/user', $data);
    }

    function id() {
        $session_data = $this->session->userdata('logged_in');
        return $session_data['id'];
    }

    function cek() {
        $level = $this->user->cek($this->id());
        if ($level) {
            if ($level == 1) {
                $level;
            } elseif ($level == 2) {
                $level;
            }
        } else {
            $level = 0;
        }
        return $level;
    }
    
    

}

?>
